#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> fib({1, 1});
    while(fib.back() < max(n, m)){
        fib.push_back(fib[fib.size() - 1] + fib[fib.size() - 2]);
    }
    cout << fib[21] << endl;
}

int main(){
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}